﻿using Microsoft.Extensions.DependencyInjection;
using MyCommon.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyExtension.ServiceExtensions
{
    /// <summary>
    /// 跨域
    /// </summary>
    public static class CorsSetup
    {
        public static void AddCorsSetup(this IServiceCollection services)
        {
            services.AddCors(c =>
            {
                c.AddPolicy(Appsettings.app("Startup", "Cors", "PolicyName"),
                    policy =>
                    {
                        policy.WithOrigins(Appsettings.app("Startup", "Cors", "IPs").Split(','))
                        .AllowAnyHeader().AllowAnyMethod();
                    });
            });
        }
    }
}
